package org.ruanjj.io;

import org.junit.Test;

import java.io.*;

public class BufferedReaderWriterMain {
    @Test
    public void test(){
        File srcFile = new File("info.txt");
        File dirFile = new File("info_copy3.txt");

        try(
                FileReader fr = new FileReader(srcFile);
                FileWriter fw = new FileWriter(dirFile);

                BufferedReader br = new BufferedReader(fr);
                BufferedWriter bw = new BufferedWriter(fw)
        ){
            String data;
           while((data = br.readLine()) != null){
               bw.write(data+"\n");
           }
            System.out.println("复制成功");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
